//
//  ViewController.m
//  ObjcGoNew
//
//  Created by 邢伟新 on 2021/4/15.
//

#import "ViewController.h"
#import "GCDViewController.h"
#import "MRacViewController.h"
#import "DDViewController.h"
#import "CopyViewController.h"
#import "AViewController.h"
#import "TimerViewController.h"
#import "NCViewController.h"
#import "GJViewController.h"
#import "KVOViewController.h"
#import "DTViewController.h"
#import "NotiViewController.h"
#import "CEViewController.h"
#import "RLViewController.h"
#import "SFViewController.h"
#import "LpxrViewController.h"
#import "FPSDisplay.h"
#import "VViewController.h"


static NSString *idenCell = @"idenCell";


@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>


@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,copy)NSArray *array;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"首页";
    [FPSDisplay shareFPSDisplay];
    
    self.array = @[@"GCD",@"mvvm",@"timer",@"多读单写",@"深浅拷贝",@"生命周期",@"内存",@"归档解档",@"KVO",@"多态",@"通知",@"分类扩展",@"runloop",@"算法",@"离屏渲染",@"视图"];
    [self _initTableViews];
}



-(void)_initTableViews{
    
    self.tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:(UITableViewStylePlain)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];

}

#pragma mark - 协议方法UITableViewDataSource


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.array.count;
    
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:idenCell];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:idenCell];
    }
    cell.textLabel.text = self.array[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

#pragma mark -UITableViewDelegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    NSString *Text = self.array[indexPath.row];
    
    //self.array = @[@"GCD",@"mvvm",@"timer",@"多读单写",@"深浅拷贝",@"生命周期"];
    
    if ([Text isEqualToString:@"GCD"]) {
        
        GCDViewController *g = [[GCDViewController alloc]init];
        [self.navigationController pushViewController:g animated:YES];
    }else if ([Text isEqualToString:@"mvvm"]){
        
        MRacViewController *mvvm = [[MRacViewController alloc]init];
        
        [self.navigationController pushViewController:mvvm animated:YES];
    }else if ([Text isEqualToString:@"timer"]){
        
        TimerViewController *mvvm = [[TimerViewController alloc]init];
        
        [self.navigationController pushViewController:mvvm animated:YES];
    }
    else if ([Text isEqualToString:@"多读单写"]){
        
        DDViewController *mvvm = [[DDViewController alloc]init];
        
        [self.navigationController pushViewController:mvvm animated:YES];
    }
    else if ([Text isEqualToString:@"深浅拷贝"]){
        
        CopyViewController *mvvm = [[CopyViewController alloc]init];
        
        [self.navigationController pushViewController:mvvm animated:YES];
    }
    else if ([Text isEqualToString:@"生命周期"]){
        
        AViewController *mvvm = [[AViewController alloc]init];
        
        [self.navigationController pushViewController:mvvm animated:YES];
    }
    else if ([Text isEqualToString:@"内存"]){
        NCViewController *nc = [[NCViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }
    else if ([Text isEqualToString:@"归档解档"]){
        GJViewController *nc = [[GJViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }
    else if ([Text isEqualToString:@"KVO"]){
        KVOViewController *nc = [[KVOViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }else if ([Text isEqualToString:@"多态"]){
        DTViewController *nc = [[DTViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }else if ([Text isEqualToString:@"通知"]){
        NotiViewController *nc = [[NotiViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }else if ([Text isEqualToString:@"分类扩展"]){
        CEViewController *nc = [[CEViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }else if ([Text isEqualToString:@"runloop"]){
        RLViewController *nc = [[RLViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }else if ([Text isEqualToString:@"算法"]){
        SFViewController *nc = [[SFViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }else if ([Text isEqualToString:@"离屏渲染"]){
        LpxrViewController *nc = [[LpxrViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }
    else if ([Text isEqualToString:@"视图"]){
        VViewController *nc = [[VViewController alloc]init];
        [self.navigationController pushViewController:nc animated:YES];
    }
}




@end
